PROC IMPORT OUT= WORK.profD 
            DATAFILE= "C:\Users\olagu\OneDrive\Old doc-2015\My SAS Files\9.4\ROI.csv" 
            DBMS=CSV REPLACE;
     GETNAMES=YES;
     DATAROW=2; 
RUN;
DATA WORK.profD;
	SET WORK.profD;

	ScaleTH = Scale/1000;
/* Create dummy variables for selected levels */
	IF FingerlingS= "On Farm" THEN Fingerling_on_farm = 1;
	ELSE Fingerling_on_farm = 0;

	IF FingerlingS= "Other farms or hatcheries" THEN Ext_Fingerling = 1;
	ELSE Ext_Fingerling = 0;

	IF Feedu= "Adds local feed" THEN Local_feed = 1;
	ELSE Local_feed = 0;

	IF Feedu= "Commercial feed only" THEN Commercial_feed = 1;
	ELSE Commercial_feed = 0;

	if Farm_Type = 'Cluster' then ClusterFarm = 1;
    else ClusterFarm = 0;

    if Farm_Type = 'Farm Site' then SiteFarm = 1;
    else SiteFarm = 0;

    if Farm_Type = 'Homestead' then HomesteadFarm = 1;
    else HomesteadFarm = 0;

	IF Ownership= "Rented_Leased" THEN Rented = 1;
	ELSE Rented = 0;

	IF Ownership= "Owned" THEN Owned = 1;
	ELSE Owned = 0;

	if Pond_Type = 'Concrete pond' then Concrete_Pond = 1;
    else Concrete_Pond = 0;

    if Pond_Type = 'Earthen pond' then Earthen_Pond = 1;
    else Earthen_Pond = 0;

    if Pond_Type = 'Mobile pond' then Mobile_Pond = 1;
    else Mobile_Pond = 0;

	Large_ = (Production_Scale = 'Large');
    Medium_ = (Production_Scale = 'Medium');
    MicroSmall_ = (Production_Scale = 'Micro-Small');
    Small_ = (Production_Scale = 'Small');

RUN;

DATA WORK.profD;
	SET WORK.profD;
		if Education in ('ND/NCE', 'Degree', 'MSC Above(Grad-studies)') then Higher_Edu = 1;
    else Higher_Edu = 0;

   	if Education = 'Secondary' then Secondary = 1;
    else Secondary = 0; 

	if Education in ('Arabic', 'Primary') then Primary_eq = 1;
    else Primary_eq = 0;    

	if Education = 'None' then No_Educ = 1;
    else No_Educ = 0;


	/* Create a new variable Education based on the newly created variables */
   if Higher_Edu = 1 then Education_ = 'Higher_Edu';
   else if Secondary = 1 then Education_ = 'Secondary';
   else if Primary_eq = 1 then Education_ = 'Primary_eq'; 
   else Education_ = 'No_Educ'; /* Assign 'No_Educ' for cases where none of the conditions match */
   RUN;

*Summary statistics of variables;
proc means data=profD;

var ROI Y FCR SCR	LCR	Pf Ps 	Pl O Py	Profit_kg
Extension_Agent	Other_Farmers	 Social_Media	Training_Courses	Scale		
EXP5_and_below	EXP6_to_10	EXP11_to_15	EXP16_and_above		
Fingerling_on_farm	Local_feed	ClusterFarm	SiteFarm	HomesteadFarm	
Higher_Edu	Secondary	Primary_eq	No_Educ	
Concrete_Pond	Earthen_Pond	Mobile_Pond ScaleTH;
run;

/* Export to CSV */
proc export data=profD
    outfile='C:\Users\olagu\OneDrive\Old doc-2015\My SAS Files\9.4\exportROI per kg.xls' /* Output file path */
    dbms=xls
    replace; /* Overwrite if the file exists */
run;

*Effectsize of prof-rated perf var on profit (Model 1);
proc glm data=profD;
model ROI=ROI3_Py ROI3_Pf ROI3_FCR ROI3_Ps ROI3_SCR ROI3_Pl ROI3_LCR ROI3_O ROI3_Y
/ ss3 effectsize;
run;

*Effectsize on ROI and ROI-rated variables (Model 2);
proc glm data=profD;
class Exp Education_ Feedu FingerlingS Pond_Type	Farm_Type;
model ROI3_Py ROI3_Pf ROI3_FCR ROI3_Ps ROI3_SCR ROI3_Pl ROI3_LCR ROI3_O ROI3_Y=  Exp	Extension_Agent Other_Farmers		
		Social_Media	Training_Courses	Education_ Feedu FingerlingS Pond_Type	Farm_Type ScaleTH 
/ ss3 effectsize solution;
run;
*Multiple linear regression with performance variables (Model 3);
proc glm data=profD;
class Exp Education_ Feedu FingerlingS Pond_Type	Farm_Type;
model ROI Py	Pf FCR	Ps SCR	Pl LCR	O Y =  EXP6_to_10 EXP11_to_15 EXP16_and_above  
		Training_Courses Extension_Agent Social_Media Other_Farmers 
        Primary_eq Secondary Higher_Edu Fingerling_on_farm Local_feed 
		ClusterFarm SiteFarm Earthen_Pond Mobile_Pond ScaleTH 
/ solution;
run;
